package org.traffometer.traffobase.model;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;

import org.junit.Test; 

/**
 * Tests operation of the StackModel instance. 
 * @author Philip Johnson
 */
public class TestStackModel  {

  /**
   * Tests all of the public operations of the StackModel instance.
   * (Note: not all operations are tested. Left as exercise for reader.) 
   * @throws Exception If problems occur during test.
   */
  @Test
  public void testStackModel() throws Exception {
    StackModel stackModel = StackModel.getInstance();
    assertSame("Checking instance identity", stackModel, StackModel.getInstance());
    stackModel.clearStack();
    stackModel.push("1");
    stackModel.push("2");
    assertEquals("Checking first top", "2", stackModel.getTop());
    assertEquals("Checking first pop", "2", stackModel.pop());
    assertEquals("Checking second pop", "1", stackModel.pop());
  }
}
